#include "key4x4.h"

unsigned char Key_Check()
{
    unsigned char temp;
    unsigned char test = 0xf0, mask = 0x01;
    for(mask=0x01; mask<0x10; mask=mask<<1)
    {
        P1 = test | ~mask;
        temp = P1 >> 4;
        if (temp != 0xF)
        {
            Delay(50);
            if(temp != 0xF)
            {
                return (mask<<4 | ~temp & 0xf);
            }
        }
    }
    return 0;
}